package cn.wolfcode.shopserverorder.service.impl;

import cn.wolfcode.order.domain.OrderInfo;
import cn.wolfcode.order.query.QueryObject;
import cn.wolfcode.order.service.IOrderInfoService;
import cn.wolfcode.shopserverorder.mapper.OrderInfoMapper;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by Chris on 2018/1/3.
 */
@Service
public class OrderInfoServiceImpl implements IOrderInfoService{

    @Autowired
    private OrderInfoMapper orderInfoMapper;
    @Override
    public PageInfo query(QueryObject qo) {
          PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
                  List<OrderInfo> list = orderInfoMapper.queryForList(qo);
                  return new PageInfo(list);
    }

    @Override
    public OrderInfo createOrder() {
        return null;
    }

    @Override
    public PageInfo selectOrderNoVerify(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
            List list = orderInfoMapper.selectOrderNoVerify(qo);
            return new PageInfo(list);
    }

    @Override
    public void changeOrderStatus(Long orderId) {
        orderInfoMapper.changeOrderStatus(orderId);
    }

    @Override
    public void changeShippingStatus(Long orderId) {
        orderInfoMapper.changeShippingStatus(orderId);
    }

    @Override
    public PageInfo selectOrderNoDeliver(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
            List list = orderInfoMapper.selectOrderNoDeliver(qo);
            return new PageInfo(list);
    }

    @Override
    public OrderInfo getOne(Integer orderId) {
        return orderInfoMapper.selectByPrimaryKey(orderId);
    }


}
